/*
 * lib2Desa - Another 2D game library in C++
 * Copyright (C) 2009 Erivaldo Xavier de Lima Filho
 *
 * This program is free software and is distributed under GNU General Public License version 3. You can modify and/or redistribute
 * it under the terms of GPL version 3 or posterior version. This program comes with NO WARRANTY, for more details, see LICENSE,
 * or <http://www.gnu.org/licenses>.
 *
 * Contact info:
 *
 *	Erivaldo Xavier de Lima Filho, desadoc@gmail.com
 *
 */

#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

#include <2DesaLua>

const struct luaL_reg lib2Desa[] = 
{
//	{"foo", foo},
	{NULL, NULL}
};

const struct luaL_reg RefCounter[] = 
{
	{"new", RefCounter_new},
	{"grab", RefCounter_grab},
	{"drop", RefCounter_drop},
	{NULL, NULL}
};

const struct luaL_reg GraphicDevice[] = 
{
	{"new", GraphicDevice_new},
	{"initScreen", GraphicDevice_initScreen},
	{NULL, NULL}
};

const struct luaL_reg Game[] = 
{
	{"new", Game_new},
	{"run", Game_run},
	{NULL, NULL}
};

extern "C" int luaopen_2Desa(lua_State *L)
{
	luaL_newmetatable(L, "lib2Desa.RefCounter");	
	luaL_register(L, NULL, RefCounter);
	
	luaL_newmetatable(L, "lib2Desa.Scene");
	
	luaL_newmetatable(L, "lib2Desa.GraphicDevice");
	luaL_register(L, NULL, GraphicDevice);
	
	luaL_newmetatable(L, "lib2Desa.Game");
	luaL_register(L, NULL, Game);
	
	luaL_register(L, "lib2Desa", lib2Desa);
	
	lua_pushstring(L, "RefCounter");
	luaL_getmetatable(L, "lib2Desa.RefCounter");
	lua_settable(L, -3);
	
	lua_pushstring(L, "GraphicDevice");
	luaL_getmetatable(L, "lib2Desa.GraphicDevice");
	lua_settable(L, -3);
	
	lua_pushstring(L, "Game");
	luaL_getmetatable(L, "lib2Desa.Game");
	lua_settable(L, -3);
	
	return 1;
}

